import './utils/utils'
import './utils/http'
// app.js
App({
  globalData: {},
  onLaunch(){
    this.getToken()
    this.getRefreshToken()
  },
  getToken(){
    wx.getStorage({
      key:'token',
      success:(res)=>{
        this.token = res.data
      }
    })
  },
  getRefreshToken(){
    // 读取本地储存中的token
    wx.getStorage({
      key:'refreshToken',
      success:(res) =>{
        // 将获取到的token存入全局数据
        this.refreshToken =res.data
      }
    })
  },
    // 存储token
  setToken(token,refreshToken) {
    wx.setStorageSync('token', `Bearer ${token}`)
    this.token = `Bearer ${token}`

    // 存refreshToken
    wx.setStorageSync('refreshToken', `Bearer ${refreshToken}`)
    this.refreshToken = `Bearer ${refreshToken}`
  },

})
